package com.xnyzc.lhy.order.controller.dapi.vehicle;

import com.xnyzc.lhy.common.entity.Rv;
import com.xnyzc.lhy.common.util.TokenUtil;
import com.xnyzc.lhy.order.entity.order.OaCOrder;
import com.xnyzc.lhy.order.entity.param.order.MileageParam;
import com.xnyzc.lhy.order.entity.param.order.TimeParam;
import com.xnyzc.lhy.order.entity.result.vehicle.DriverVehInfo;
import com.xnyzc.lhy.order.entity.vehicle.OaSysVehicle;
import com.xnyzc.lhy.order.service.vehicle.IOaDDriverVehicleService;
import com.xnyzc.lhy.order.service.vehicle.VehicleIntegrationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;

/**
 * 车辆信息
 */
@RestController
@RequestMapping(value = "/dapi/vehicleIntegration")
public class VehicleIntegrationController {

    @Autowired
    private VehicleIntegrationService vehicleIntegrationService;

    @Autowired
    private IOaDDriverVehicleService iOaDDriverVehicleService;

    /**
     * 车辆信息
     *
     * @return
     */
    @GetMapping(value = "/getVehicleIntegration")
    public Rv getVehicleIntegration() {
        Long driverId = TokenUtil.getTokenUserId();
        return Rv.wrap(vehicleIntegrationService.getVehicleIntegration(driverId));
    }

    /**
     * netty 获取司机车辆信息
     *
     * @return
     */
    @GetMapping(value = "/getDDriverVehicleInfo")
    public DriverVehInfo getDDriverVehicleInfo(String vehicleId) {
        return iOaDDriverVehicleService.getDDriverVehicleInfo(vehicleId);
    }

    /**
     * netty 获取车辆信息
     *
     * @return
     */
    @GetMapping(value = "/getSysVehicleInfo")
    public OaSysVehicle getSysVehicleInfo(Long vehicleId) {
        OaSysVehicle oaSysVehicle = iOaDDriverVehicleService.getSysVehicleInfo(vehicleId);
        return oaSysVehicle;
    }

    /**
     * netty 获取里程费
     *
     * @return
     */
    @PostMapping(value = "/getMileageFee")
    public BigDecimal getMileageFee(@RequestBody MileageParam param) {
        BigDecimal mileageFee = iOaDDriverVehicleService.getMileageFee(param.getRulesId(), param.getDate(), param.getSubtract(), param.getTotailMileagel(), param.getTag());
        return mileageFee;
    }

    /**
     * netty 获取时长费
     *
     * @return
     */
    @PostMapping(value = "/getTimeFee")
    public BigDecimal getTimeFee(@RequestBody TimeParam param) {
        BigDecimal timeFee = iOaDDriverVehicleService.getTimeFee(param.getRulesId(), param.getCurrentTime(), param.getTotalTime(), param.getTag(), param.getStartDate());
        return timeFee;
    }


    /**
     * netty 获取时长费
     *
     * @return
     */
    @PostMapping(value = "/getTimeFeeByIdOrder")
    public OaCOrder getTimeFeeByIdOrder(@RequestBody OaCOrder order) {
        OaCOrder oaCOrder = iOaDDriverVehicleService.getTimeFee(order);
        return oaCOrder;
    }

    @PostMapping(value = "/getMileageFeeByOrder")
    public OaCOrder getMileageFeeByOrder(@RequestBody OaCOrder order) {
        OaCOrder oaCOrder = iOaDDriverVehicleService.getMileageFee(order);
        return oaCOrder;
    }

    @PostMapping(value = "/getDistanceFeeByOrder")
    public OaCOrder getDistanceFeeByOrder(@RequestBody OaCOrder order) {
        OaCOrder oaCOrder = iOaDDriverVehicleService.getDistanceFee(order);
        return oaCOrder;
    }

    /**
     * netty 获取远途费
     *
     * @return
     */
    @PostMapping(value = "/getDistanceFee")
    public BigDecimal getDistanceFee(@RequestBody MileageParam param) {
        BigDecimal distanceFee = iOaDDriverVehicleService.getDistanceFee(param.getRulesId(), param.getDate(), param.getSubtract(), param.getTotailMileagel(), param.getTag());
        return distanceFee;
    }

    /**
     * netty 获取远途费
     *
     * @return
     */
    @PostMapping(value = "/getDrawFee")
    public BigDecimal getDrawFee(@RequestParam("totalBillFee") BigDecimal totalBillFee, @RequestParam("rulesId") String rulesId) {
        BigDecimal drawFee = iOaDDriverVehicleService.getDrawFee(rulesId, totalBillFee);
        return drawFee;
    }

}
